﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<GlassStore.Models.Glass>" %>
<script src="/Scripts/MicrosoftAjax.js" type="text/javascript"></script>
<script src="/Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script>
<script src="/Scripts/MicrosoftMvcValidation.js" type="text/javascript"></script>
<script src="/Scripts/FileUpload.js" type="text/javascript"></script>
<script src="/Scripts/jquery-1.4.1.min.js"type="text/javascript"></script>

<script type="text/javascript">
    var styles = new Array();
    styles["光学架"] = ["全框", "半框", "无框", "超大", "特窄"];
    styles["太阳镜"] = ["男款", "女款"];

    $(document).ready(function () {
        UpdateStyleDetail();
        $("#Glass_Style").change(function () { UpdateStyleDetail(); });
    });

    function UpdateStyleDetail() {
        //$("#Glass_StyleDetail").empty();
        var style = document.getElementById("Glass_Style");
        var styleDetail = document.getElementById("Glass_StyleDetail");
        var styleDetailValue = document.getElementById("Glass_StyleDetail_Value");
        styleDetail.length = 0; //清空下拉列表
        for (var index in styles[style.value]) {
            var option = new Option(styles[style.value][index], styles[style.value][index])
            styleDetail.options.add(option);
            if (styleDetailValue.value == styles[style.value][index]) {
                option.selected = true;
            }
        }
    };

</script>

<div id="edit-glass">
  <p class="edit-glass-title">
    基本信息</p>
  <div class="editor-label">
    <%: Html.LabelFor(model => model.GlassName) %>
  </div>
  <div class="editor-field">
    <%: Html.TextBoxFor(model => model.GlassName) %>
    <%: Html.ValidationMessageFor(model => model.GlassName) %>
  </div>
  <div class="editor-label">
    <%: Html.LabelFor(model => model.Brand) %>
  </div>
  <div class="editor-field">
    <%: Html.TextBoxFor(model => model.Brand) %>
    <%: Html.ValidationMessageFor(model => model.Brand) %>
  </div>
  <div class="editor-label">
    <%: Html.LabelFor(model => model.Material) %>
  </div>
  <div class="editor-field">
    <%: Html.DropDownList("Material", new SelectList(ViewData["MaterialList"] as IEnumerable, string.IsNullOrEmpty(Model.Material) ? (ViewData["MaterialList"] as List<string>)[0] : Model.Material))%>
    <%: Html.ValidationMessageFor(model => model.Material) %>
  </div>

  <div class="editor-label">
    <%: Html.LabelFor(model => model.Style) %>
  </div>
  <div class="editor-field">
    <%: Html.DropDownList("Style", new SelectList(ViewData["StyleList"] as IEnumerable, string.IsNullOrEmpty(Model.Style) ? (ViewData["StyleList"] as List<string>)[0] : Model.Style))%>
    <%: Html.ValidationMessageFor(model => model.Style) %>
  </div>

  <div class="editor-label">
    <%: Html.LabelFor(model => model.StyleDetail) %>
  </div>
  <div class="editor-field">
    <select id="Glass_StyleDetail" name="Glass.StyleDetail"></select>
    <input id="Glass_StyleDetail_Value" value="<%:Model.StyleDetail %>" type="hidden" />
    <%: Html.ValidationMessageFor(model => model.StyleDetail)%>
  </div>

  <div class="editor-label">
    <%: Html.LabelFor(model => model.Serial) %>
  </div>
  <div class="editor-field">
    <%: Html.TextBoxFor(model => model.Serial) %>
    <%: Html.ValidationMessageFor(model => model.Serial) %>
  </div>

  <div class="editor-label">
    <%: Html.LabelFor(model => model.Price) %>
  </div>
  <div class="editor-field">
    <%: Html.TextBoxFor(model => model.Price, String.Format("{0:F}", Model.Price)) %>
    <%: Html.ValidationMessageFor(model => model.Price) %>
  </div>
  <div class="editor-label">
    <%: Html.LabelFor(model => model.Color) %>
  </div>
  <div class="editor-field">
    <%: Html.TextBoxFor(model => model.Color)%>
    <%: Html.ValidationMessageFor(model => model.Color)%>
  </div>
  <div class="editor-label">
    <%: Html.LabelFor(model => model.Size) %>
  </div>
  <div class="editor-field">
    <%: Html.TextBoxFor(model => model.Size)%>
    <%: Html.ValidationMessageFor(model => model.Size)%>
  </div>
  <div class="editor-label">
    <%: Html.LabelFor(model => model.TopSale) %>
  </div>
  <div class="editor-field">
    <%: Html.TextBoxFor(model => model.TopSale)%>
    <%: Html.ValidationMessageFor(model => model.TopSale)%>
  </div>
  <div class="editor-label">
    <%: Html.LabelFor(model => model.TopNew) %>
  </div>
  <div class="editor-field">
    <%: Html.TextBoxFor(model => model.TopNew)%>
    <%: Html.ValidationMessageFor(model => model.TopNew)%>
  </div>
  <div class="editor-label">
    <%: Html.LabelFor(model => model.TopBargain) %>
  </div>
  <div class="editor-field">
    <%: Html.TextBoxFor(model => model.TopBargain)%>
    <%: Html.ValidationMessageFor(model => model.TopBargain)%>
  </div>
  <div class="editor-label">
    <%: Html.LabelFor(model => model.Thumbnail) %>
  </div>
  <div class="editor-field">
    <input type="file" name="ThumbnailUpload" /><br />
  </div>
  <div class="editor-label">
    <%: Html.LabelFor(model => model.Description) %>
  </div>
  <div class="editor-field">
    <%: Html.TextAreaFor(model => model.Description, 10, 80, null) %>
<%--    <%: MvcHtmlString.Create(Html.FckEditor("FCKTextBox", new FckConfig { Width = "600", Height = "500", Skin = FckSkin.Office2003, ToolbarSet = FckToolbarSet.Basic }))%>--%>
    <%: Html.ValidationMessageFor(model => model.Description) %>
  </div>
  <p class="edit-glass-title">
    更多照片</p>
  <div id="fileUpload" class="editor-field">
    <input type="file" name="FileUpload1" /><br />
  </div>
  <div>
    <input type="button" value="再传一张照片" onclick="add()" />
    <input type="button" value="少传一张照片" onclick="remove()" />
  </div>
  <p class="edit-glass-title">
    所属类别</p>
  <div id="edit-glass-calalogue">
    <% foreach (var top in ViewData["TopCatalogues"] as List<GlassStore.Models.TopCatalogue>)
       {%>
    <div>
      <%:top.Name %>:
        <% foreach (var sub in top.SubCatalogues.ToList())
           {
             if (Model.GlassCatalogues.ToList().Exists(c => c.SubCatalogueId == sub.SubCatalogueId))
             { %>
        <input type="checkbox" name="SelectedCatalogue" value="<%: sub.SubCatalogueId %>"
          checked="checked" />
        <%}
           else
           { %>
        <input type="checkbox" name="SelectedCatalogue" value="<%: sub.SubCatalogueId %>" />
        <%} %>
        <label>
          <%: sub.Name %></label>
        <%} %>
        <br />
    </div>
    <%} %>
  </div>
</div>
